package com.laity.tvolatile;

/**
 * @author: Laity
 * @Project: JavaLaity
 * @Package: com.laity.tvolatile.JMMDEMO
 * @Date: 2023年12月13日 16:12
 * @Description: volatile 可见性
 */

public class JmmDemo {

    private static volatile int i = 0;

    public static void main(String[] args) {

        new Thread(() -> {
            while (i == 0) {

            }
        }, "t1").start();

        try {
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        }

        i = 1;

        System.out.println("结束标志：" + i);
    }
}
